import axios from 'axios'
import {
    CHANGGE_DETAIL
} from './types'

const changeDetail = (title, content) => ({
    type: CHANGGE_DETAIL,
    title,
    content
})

export const getDtail = (id) => {
    return (dispatch) => {
        axios.get('/api/detail.json?id=' + id)
            .then(res => {
                // console.log(res.data)
                const result = res.data.data
                dispatch(changeDetail(result.title, result.content))
            })
    }
}